package com.wbl.train.common.exception;

import com.wbl.train.common.result.ResultCode;

public class ApplicationException extends RuntimeException{
    /**
     * 统一的异常信息枚举类
     */
    private final ResultCode resultCode;

    public ApplicationException(String message) {
        super(message);
        this.resultCode = ResultCode.SERVER_ERROR;
    }

    public ApplicationException(Throwable cause) {
        super(cause);
        this.resultCode = ResultCode.SERVER_ERROR;
    }

    public ApplicationException(String message, Throwable cause) {
        super(message, cause);
        this.resultCode = ResultCode.SERVER_ERROR;
    }

    public ApplicationException(ResultCode resultCode) {
        super(resultCode.getErrorMessage());
        this.resultCode = resultCode;
    }

    public ApplicationException(ResultCode resultCode, String message) {
        super(message);
        this.resultCode = resultCode;
    }

    public ApplicationException(ResultCode resultCode, Throwable cause) {
        super(cause);
        this.resultCode = resultCode;
    }

    public ApplicationException(ResultCode resultCode, String message, Throwable cause) {
        super(message, cause);
        this.resultCode = resultCode;
    }

    public ResultCode getResultCode() {
        return resultCode;
    }
}
